<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import =  "org.apache.commons.beanutils.PropertyUtils,
                    com.broadvision.web.util.ViewDynaBean,
                    java.util.List"
%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<script language="JavaScript">

  //
  function closeWindow() {
    self.close();
  }

  function doExportReport(formName) {
    var myform = document.forms[formName];
    if (myform == null) {
      return false;
    }
    myform.doExport.value = true;
    myform.action = '<c:url value="${reportCriteriaForm.map.reportAction}"/>';
    myform.submit();
    myform.doExport.value = false;
    return false;
  }

  function doPrintReport() {
    window.print();
    return false;
  }

  function gotoFirstPage(formName) {
    if (doValidateEntriesPerPage(formName) == false) {
      return false;
    }
    var thisForm = document.forms[formName];
    if (thisForm != null) {
      thisForm.currentPageNumber.value = 1;
      thisForm.submit();
    }
  }

  function gotoPreviousPage(formName) {
    if (doValidateEntriesPerPage(formName) == false) {
      return false;
    }
    var thisForm = document.forms[formName];
    if (thisForm != null) {
      var currentPageNumber = thisForm.currentPageNumber.value;
      currentPageNumber--;
      if (thisForm.entriesPerPage.value != <bean:write name="reportCriteriaForm" property="entriesPerPage"/>) {
        currentPageNumber = 1;
      }
      if (currentPageNumber > 0) {
        thisForm.currentPageNumber.value = currentPageNumber;
        thisForm.submit();
      }
    }
  }

  function gotoNextPage(formName) {
    if (doValidateEntriesPerPage(formName) == false) {
      return false;
    }
    var thisForm = document.forms[formName];
    if (thisForm != null) {
      var currentPageNumber = thisForm.currentPageNumber.value;
      currentPageNumber++;
      if (thisForm.entriesPerPage.value != <bean:write name="reportCriteriaForm" property="entriesPerPage"/>) {
        currentPageNumber = 1;
      }
      if (currentPageNumber <= thisForm.totalPageNumber.value) {
        thisForm.currentPageNumber.value = currentPageNumber;
        thisForm.submit();
      }
    }
  }

  function gotoLastPage(formName) {
    if (doValidateEntriesPerPage(formName) == false) {
      return false;
    }
    var thisForm = document.forms[formName];
    if (thisForm != null) {
      if (thisForm.entriesPerPage.value != <bean:write name="reportCriteriaForm" property="entriesPerPage"/>) {
        thisForm.currentPageNumber.value = 1;
      }
      else {
        thisForm.currentPageNumber.value = thisForm.totalPageNumber.value;
      }
      thisForm.submit();
    }
  }


  function doGo(formName) {
    if (doValidateEntriesPerPage(formName) == false) {
      return false;
    }
    var thisForm = document.forms[formName];
    if (thisForm != null) {
      if (thisForm.entriesPerPage.value != <bean:write name="reportCriteriaForm" property="entriesPerPage"/>) {
        thisForm.currentPageNumber.value = 1;
        return true;
      }
    }
    return false;
  }

  function checkNumberOnly(e) {
    var charCode = (navigator.appName == "Netscape") ? e.which : e.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
      return false;
    }
    else {
      return true;
    }
  }

  function doValidateEntriesPerPage(formName) {
    var thisForm = document.forms[formName];
    if (thisForm != null) {
      if (thisForm.entriesPerPage == null) {
        return true;
      }
      var entriesPerPageInt = parseInt(thisForm.entriesPerPage.value);
      if (isNaN(entriesPerPageInt)) {
        alert("<bean:message key="bp.common.pagination.validation.itemsPerPage" bundle="bp.messages"/>");
        thisForm.entriesPerPage.select();
        thisForm.entriesPerPage.focus();
        return false;
      }
      if (thisForm.entriesPerPage.value < 1 || thisForm.entriesPerPage.value > 2147483647) {
        alert("<bean:message key="bp.common.pagination.validation.itemsPerPage" bundle="bp.messages"/>");
        thisForm.entriesPerPage.select();
        thisForm.entriesPerPage.focus();
        return false;
      }
      else {
        return true;
      }
    }
    return false;
  }

</script>

<html:form action="/bp/participantCompletion.do&fromCache=yes" onsubmit="return doGo('reportCriteriaForm');">
<html:hidden name="reportCriteriaForm" property="isProcessAdmin"/>
<html:hidden name="reportCriteriaForm" property="processChoice"/>
<html:hidden name="reportCriteriaForm" property="processName"/>
<html:hidden name="reportCriteriaForm" property="definitionVersion"/>
<html:hidden name="reportCriteriaForm" property="managerAlias"/>
<html:hidden name="reportCriteriaForm" property="participantAlias"/>
<html:hidden name="reportCriteriaForm" property="criteriaAction"/>
<html:hidden name="reportCriteriaForm" property="listAction"/>
<html:hidden name="reportCriteriaForm" property="reportAction"/>
<html:hidden name="reportCriteriaForm" property="processOid"/>
<html:hidden name="reportCriteriaForm" property="doExport"/>
<html:hidden name="reportCriteriaForm" property="currentPageNumber"/>
<html:hidden name="reportCriteriaForm" property="totalPageNumber"/>
<html:hidden name="reportCriteriaForm" property="lastPage"/>
<html:hidden name="reportCriteriaForm" property="reportSubjectNameKey"/>
<html:hidden name="reportCriteriaForm" property="dateRangeKey"/>
<html:hidden name="reportCriteriaForm" property="dateFrom.month"/>
<html:hidden name="reportCriteriaForm" property="dateFrom.day"/>
<html:hidden name="reportCriteriaForm" property="dateFrom.year"/>
<html:hidden name="reportCriteriaForm" property="dateFrom.hour"/>
<html:hidden name="reportCriteriaForm" property="dateFrom.minute"/>
<html:hidden name="reportCriteriaForm" property="dateFrom.ind"/>
<html:hidden name="reportCriteriaForm" property="dateTo.month"/>
<html:hidden name="reportCriteriaForm" property="dateTo.day"/>
<html:hidden name="reportCriteriaForm" property="dateTo.year"/>
<html:hidden name="reportCriteriaForm" property="dateTo.hour"/>
<html:hidden name="reportCriteriaForm" property="dateTo.minute"/>
<html:hidden name="reportCriteriaForm" property="dateTo.ind"/>
<html:hidden name="reportCriteriaForm" property="reportId"/>
<!-- Zone 5 starts here.  -->
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="generalWrapRight">
        <html:button property="closeWinBtn" styleClass="inputButton" onclick="javascript:closeWindow()">
          <bean:message key="button.close"  bundle="bp.messages"/>
        </html:button>
      </div>
      <div class="pageTitle">
        <span class="left">
          <bean:message name="reportCriteriaForm" property="reportSubjectNameKey" bundle="bp.messages"/>
        </span>
        <span class="right">&nbsp;</span>
      </div>
      <div class="pageButtonWrap" align="right">
        <html:link href="#" onclick="javascript:doPrintReport();">
          <img src="<%=request.getContextPath()%>/bp/images/icons/print.gif" width="20" height="20" border="0" alt='<bean:message key="image.alt.print" bundle="bp.messages"/>' title='<bean:message key="image.alt.print" bundle="bp.messages"/>' align="absmiddle">
          <bean:message key="bp.report.common.print" bundle="bp.messages"/>
        </html:link>
        &nbsp;
        <html:link href="#" onclick="javascript:doExportReport('reportCriteriaForm');">
          <img src="<%=request.getContextPath()%>/bp/images/icons/export_data.gif" width="20" height="20" border="0" alt='<bean:message key="image.alt.exportReport" bundle="bp.messages"/>' title='<bean:message key="image.alt.exportReport" bundle="bp.messages"/>' align="absmiddle">
          <bean:message key="bp.report.criteria.exportReport" bundle="bp.messages"/>
        </html:link>
      </div>
      <div class="pageSubtitle">
        <span class="left"><bean:message key="bp.report.criteria.reportingCriteria" bundle="bp.messages"/></span>
        <span class="right">&nbsp;</span>
      </div>
      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Process summary">
        <tr>
          <td class="label" width="20%" nowrap>
            <bean:message key="bp.report.criteria.participant" bundle="bp.messages"/>
          </td>
          <td class="labelField" width="80%" colspan="2">
            <bean:write name="reportCriteriaForm" property="participantAlias"/>
          </td>
        </tr>
        <tr>
          <td class="label" width="20%" nowrap>
            <bean:message key="bp.report.criteria.processModel" bundle="bp.messages"/>
          </td>
          <td class="labelField" width="80%" colspan="2">
            <logic:equal name="reportCriteriaForm" property="processChoice" value="0">
              <logic:equal name="reportCriteriaForm" property="isProcessAdmin" value="true">
                <bean:message key="bp.report.common.allModels" bundle="bp.messages"/>
              </logic:equal>
              <logic:equal name="reportCriteriaForm" property="isProcessAdmin" value="false">
                <bean:message key="bp.report.common.allMyModels" bundle="bp.messages"/>
              </logic:equal>
            </logic:equal>
            <logic:equal name="reportCriteriaForm" property="processChoice" value="1">
              <bean:write name="reportCriteriaForm" property="processName"/>
            </logic:equal>
            <logic:equal name="reportCriteriaForm" property="processChoice" value="2">
              <bean:message key="bp.report.common.modelsByManager" bundle="bp.messages"/>
            </logic:equal>
          </td>
        </tr>
        <logic:equal name="reportCriteriaForm" property="processChoice" value="1">
          <tr>
            <td class="label" width="20%" nowrap>
              <bean:message key="bp.report.criteria.modelVersion" bundle="bp.messages"/>
            </td>
            <td class="labelField" width="80%" colspan="2">
              <bean:write name="reportCriteriaForm" property="definitionVersion"/>
            </td>
          </tr>
        </logic:equal>
        <logic:equal name="reportCriteriaForm" property="processChoice" value="2">
          <tr>
            <td class="label" width="20%" nowrap>
              <bean:message key="bp.report.criteria.processModelManager" bundle="bp.messages"/>
            </td>
            <td class="labelField" width="80%" colspan="2">
              <bean:write name="reportCriteriaForm" property="managerAlias"/>
            </td>
          </tr>
        </logic:equal>
        <tr>
          <td class="label" width="20%" nowrap>
            <bean:message name="reportCriteriaForm" property="dateRangeKey" bundle="bp.messages"/>
          </td>
          <td class="labelField" width="10%" nowrap>
            <bean:message key="bp.report.criteria.dateFrom" bundle="bp.messages"/>
          </td>
          <td class="labelField" width="70%" nowrap>
            <bean:write name="participantCompletionView" property="dateFrom" bundle="bp.messages" formatKey="format.datetime.long"/>
          </td>
        </tr>
        <tr>
          <td class="label" width="20%" nowrap>&nbsp;</td>
          <td class="labelField" width="10%" nowrap>
            <bean:message key="bp.report.criteria.dateTo" bundle="bp.messages"/>
          </td>
          <td class="labelField" width="70%" nowrap>
            <bean:write name="participantCompletionView" property="dateTo" bundle="bp.messages" formatKey="format.datetime.long"/>
          </td>
        </tr>
      </table>
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
        <tr class="listHeader">
          <logic:notEqual name="reportCriteriaForm" property="processChoice" value="1">
            <th id="ModelName" align="left">
              <bean:message key="bp.report.header.modelName" bundle="bp.messages"/>
            </th>
            <th id="VersionNumber" align="left">
              <bean:message key="bp.report.header.versionNumber" bundle="bp.messages"/>
            </th>
          </logic:notEqual>
          <th id="InstanceName" align="left">
            <bean:message key="bp.report.header.instanceName" bundle="bp.messages"/>
          </th>
          <th id="taskName" align="left">
            <bean:message key="bp.report.header.taskName" bundle="bp.messages"/>
          </th>
          <th id="CompletionDate" align="left">
            <bean:message key="bp.report.header.completionDate" bundle="bp.messages"/>
          </th>
          <th id="CompletionTime" align="left">
            <bean:message key="bp.report.header.completionTime" bundle="bp.messages"/>
          </th>
        </tr>
        <logic:equal name="participantCompletionView" property="completionTimeCount" value="0">
          <tr class="listEven">
            <logic:notEqual name="reportCriteriaForm" property="processChoice" value="1">
              <td align="center" colspan="6">
                <bean:message key="bp.report.common.instance.noMatch" bundle="bp.messages"/>
              </td>
            </logic:notEqual>
            <logic:equal name="reportCriteriaForm" property="processChoice" value="1">
               <td align="center" colspan="4">
                <bean:message key="bp.report.common.instance.noMatch" bundle="bp.messages"/>
              </td>
           </logic:equal>
          </tr>
        </logic:equal>
        <logic:notEqual name="participantCompletionView" property="completionTimeCount" value="0">
          <logic:iterate id="completionTime" name="participantCompletionView" property="completionTimes" indexId="i">
            <tr class="<%=i.intValue() % 2 == 0 ? "listEven" : "listOdd" %>">
              <logic:notEqual name="reportCriteriaForm" property="processChoice" value="1">
                <td headers="ModelName">
                  <bean:write name="completionTime" property="modelName"/>
                </td>
                <td headers="VersionNumber" align="right">
                  <bean:write name="completionTime" property="versionNumber"/>
                </td>
              </logic:notEqual>
              <td headers="InstanceName">
                <bean:write name="completionTime" property="instanceName"/>
              </td>
              <td headers="TaskName">
                <bean:write name="completionTime" property="taskName"/>
              </td>
              <td headers="CompletionDate">
                <bean:write name="completionTime" property="completionDate" bundle="bp.messages" formatKey="format.datetime.long"/>
              </td>
              <td headers="completionTime">
                <bean:define id="elapsedTimeDays" name="completionTime" property="elapsedTimeDays"/>
                <bean:define id="elapsedTimeHours" name="completionTime" property="elapsedTimeHours"/>
                <bean:define id="elapsedTimeMinutes" name="completionTime" property="elapsedTimeMinutes"/>
                <bean:message key="bp.report.common.numberOfDaysHoursMinutes"
                  arg0="<%= elapsedTimeDays.toString() %>"
                  arg1="<%= elapsedTimeHours.toString() %>"
                  arg2="<%= elapsedTimeMinutes.toString() %>" bundle="bp.messages"/>
              </td>
            </tr>
          </logic:iterate>
        </logic:notEqual>
      </table>
      <logic:notEqual name="participantCompletionView" property="completionTimeCount" value="0">
        <div class="pagination">
          <bean:message key="bp.report.criteria.show" bundle="bp.messages"/>
          <html:text name="reportCriteriaForm" property="entriesPerPage" size="10" maxlength="10" onkeypress="return checkNumberOnly(event)"/>
          <bean:message key="bp.report.criteria.itemsPerPage" bundle="bp.messages"/>
          &nbsp;
          <html:submit property="go" styleClass="inputButton"
            onclick="return doGo('reportCriteriaForm');">
            <bean:message key="button.goto" bundle="bp.messages"/>
          </html:submit>
          <logic:greaterThan name="reportCriteriaForm" property="totalPageNumber" value="1">
            &nbsp;&nbsp;&nbsp;
            <logic:greaterThan name="reportCriteriaForm" property="currentPageNumber" value="0">
              <logic:greaterThan name="reportCriteriaForm" property="totalPageNumber" value="1">
                <logic:greaterThan name="reportCriteriaForm" property="currentPageNumber" value="1">
                  <a href="#" class="paginationBtn" onclick="javascript:gotoFirstPage('reportCriteriaForm')">
                    <bean:message key="bp.common.pagination.first" bundle="bp.messages"/></a>
                  <a href="#" class="paginationBtn" onclick="javascript:gotoPreviousPage('reportCriteriaForm')">
                    <bean:message key="bp.common.pagination.previous" bundle="bp.messages"/></a>
                </logic:greaterThan>
              </logic:greaterThan>
              <bean:define id="currentPageNumberAttr" name="reportCriteriaForm" property="currentPageNumber"/>
              <bean:define id="totalPageNumberAttr" name="reportCriteriaForm" property="totalPageNumber"/>
              <% Integer currentPageNumberInt = (Integer)pageContext.getAttribute("currentPageNumberAttr"); %>
              <% Integer totalPageNumberInt = (Integer)pageContext.getAttribute("totalPageNumberAttr"); %>
              <bean:message key="bp.common.pagination.pageOf"
                arg0="<%= currentPageNumberInt.toString() %>"
                arg1="<%= totalPageNumberInt.toString() %>" bundle="bp.messages"/>
              <logic:greaterThan name="reportCriteriaForm" property="totalPageNumber" value="1">
                <logic:equal name="reportCriteriaForm" property="lastPage" value="false">
                  <a href="#" class="paginationBtn" onclick="javascript:gotoNextPage('reportCriteriaForm')">
                    <bean:message key="bp.common.pagination.next" bundle="bp.messages"/></a>
                  <a href="#" class="paginationBtn" onclick="javascript:gotoLastPage('reportCriteriaForm')">
                    <bean:message key="bp.common.pagination.last" bundle="bp.messages"/></a>
                </logic:equal>
              </logic:greaterThan>
            </logic:greaterThan>
          </logic:greaterThan>
        </div>
      </logic:notEqual>
    </td>
  </tr>
</table>
<!--end zone 5 content here -->
</html:form>

